# -*- coding:utf-8 -*-
# @Author   : ZGS
# @Time     : 2020/12/30 17:43
# @FileName : utils.py
# 我拿青春赌明天!
import datetime


def get_time():
    """
        获取时间函数
    :return: 格式化时间
    """
    now_time = datetime.datetime.now()
    year = now_time.year
    month = now_time.month
    day = now_time.day
    hour = now_time.hour
    minute = now_time.minute
    second = now_time.second
    return f"{year}年{month}月{day}日 {hour}:{minute}:{second}"


def rename_column(df, dict_=None):
    """
    修改字段名字
    :param df:
    :param dict_:
    :return:
    """
    if isinstance(dict_, dict):
        for k, v in dict_.items():
            df[k] = df[v]
            df = df.drop(v, axis=1)
        return df
    else:
        raise TypeError("不是dict类型!")


def heal_head_add(data, live=1):
    if isinstance(data, list):
        # 治愈增加
        num_list = []
        for n in range(len(data)):
            if n == 0:
                number = 0
            else:
                yearstoday = data[n-1]
                today = data[n]
                if live:
                    number = today['heal']-yearstoday['heal']
                else:
                    number = today['dead']-yearstoday['dead']
            num_list.append(number)
        return num_list


if __name__ == '__main__':

    print(get_time())
